package com.jensen.jpa.service;
import com.jensen.jpa.domain.Customer;
import com.jensen.jpa.domain.CustomerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Jensen on 2015/7/13.
 */
@Service
public class CustomerService {

    @Autowired
    CustomerRepository repository;

   public Customer register(Customer customer){
       return this.repository.save(customer);
   }

   public void disable(long id){
       Customer c=this.repository.findOne(id);
       //TODO
       this.repository.save(c);

   }

    public List<Customer> findByFirstName(String name) {
       return this.repository.findByFirstName(name);
    }

    public List<Customer> findAll(){
        return (List<Customer>)this.repository.findAll();
    }
}
